package com.g3.zoosite.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.g3.zoosite.mapper.DwWaterWorldMapper;
import com.g3.zoosite.model.DwWaterWorld;
import com.g3.zoosite.service.IDwWaterWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 水上世界信息表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-09-28
 */
@Service
public class DwWaterWorldServiceImpl extends ServiceImpl<DwWaterWorldMapper, DwWaterWorld> implements IDwWaterWorldService {

    @Autowired(required = false)
    private DwWaterWorldMapper waterWorldMapper;

    @Value("${image-server}")
    private String imageServer;

    /**
     * 查询所有水上项目业务逻辑层方法
     * @return
     */
    @Override
    public List<DwWaterWorld> findWachWorlds() {
        List<DwWaterWorld> waterWorlds = waterWorldMapper.selectList(null);
        for (int i=0;i<waterWorlds.size();i++){
            DwWaterWorld dwWaterWorld = waterWorlds.get(i);
            dwWaterWorld.setImagePath(imageServer+dwWaterWorld.getImagePath());
        }
        return waterWorlds;
    }

    /**
     * 通过id获取水上项目业务逻辑
     * @param id
     * @return
     */
    @Override
    public DwWaterWorld findWaterWorldById(Integer id) {
        DwWaterWorld waterWorld = waterWorldMapper.selectById(id);
        //拼接图片服务器和图片路径
        waterWorld.setImagePath(imageServer+waterWorld.getImagePath());
        return waterWorld;
    }
}
